package com.uenpay.oem.widget.dialog;


import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.uenpay.oem.R;

import butterknife.OnClick;

/**
 * Created by PS on 2017/6/20.
 */

public class WithdrawresumeDialog extends Dialog {
    private final Activity activity;
    private oncloseclickListener nocloseclickListener;
    private onclickforgetListener onforgetlisten;
    private onresumeloadListener onclickresumeloadlistener;

    public WithdrawresumeDialog(Context context, Activity activity) {
        super(context, R.style.dialog_custom);
        this.activity=activity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_resume);
        Window window = getWindow();
        window.setGravity(Gravity.CENTER); // 此处可以设置dialog显示的位置为居中
        // 按空白处不能取消动画
        setCanceledOnTouchOutside(false);


        WindowManager m = activity.getWindowManager();
        Display d = m.getDefaultDisplay(); // 获取屏幕宽、高度
        WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值
        p.width = (int) (d.getWidth() * 0.8); // 宽度设置为屏幕的0.65，根据实际情况调整
        window.setAttributes(p);

        initview();

    }

    private void initview() {
        findViewById(R.id.dialog_close_code).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (nocloseclickListener!=null) {
                    nocloseclickListener.oncloseClick();
                }
            }
        });


        findViewById(R.id.btn_cancle).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onforgetlisten!=null){
                    onforgetlisten.onclickListener();
                }
            }
        });


        findViewById(R.id.btn_comfirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onclickresumeloadlistener!=null){
                    onclickresumeloadlistener.onresumeListener();
                }
            }
        });
    }




    public void setoncloseListener(oncloseclickListener onclseclickListener) {

        this.nocloseclickListener = onclseclickListener;
    }

    /**
     * 设置确定关闭 和添加被点击的接口
     */
    public interface oncloseclickListener {
        void oncloseClick();
    }


    /**
     * 设置忘记密码的方法
     */
    public void setonforgetListen(onclickforgetListener onclickforgetListener){
        this.onforgetlisten=onclickforgetListener;
    }

    /**
     * 设置点击忘记密码的接口
     */
    public interface  onclickforgetListener{
        void onclickListener();
    }

    /**
     * 重新输入的接口
     */

    public interface  onresumeloadListener{
        void onresumeListener();
    }

    public void setonclickresumeLisetener(onresumeloadListener onresumeloadListener){
        this.onclickresumeloadlistener=onresumeloadListener;
    }

}
